﻿namespace HRM.CORE.REPORT
{
    using APP.HELPER.Utils.Security;
    using DevExpress.Utils;
    using DevExpress.XtraCharts;
    using DevExpress.XtraPrinting;
    using DevExpress.XtraReports.UI;
    using Extra.ERP;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Printing;

    public class rptChartSalary : XtraReport
    {
        private BottomMarginBand BottomMargin;
        private XRChart chartSalary;
        private IContainer components;
        private DetailBand Detail;
        private DateTime m_FromDate;
        private DateTime m_ToDate;
        private PageFooterBand PageFooter;
        private XRPictureBox ptPhoto;
        private TopMarginBand TopMargin;
        private XRLabel txtAddress;
        private XRLabel txtCompany;
        private XRLabel txtDate;
        private XRLabel xrLabel2;
        private XRLabel xrLabel3;
        private XRLabel xrLabel4;
        private XRTable xrTable3;
        private XRTableCell xrTableCell10;
        private XRTableCell xrTableCell12;
        private XRTableCell xrTableCell7;
        private XRTableCell xrTableCell9;
        private XRTableRow xrTableRow3;
        private XRTableRow xrTableRow4;

        public rptChartSalary()
        {
            this.components = null;
            this.InitializeComponent();
        }

        public rptChartSalary(DateTime FromDate, DateTime ToDate)
        {
            this.components = null;
            this.InitializeComponent();
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            XYDiagram diagram = new XYDiagram();
            Series series = new Series();
            SideBySideBarSeriesLabel label = new SideBySideBarSeriesLabel();
            Series series2 = new Series();
            SideBySideBarSeriesLabel label2 = new SideBySideBarSeriesLabel();
            SideBySideBarSeriesLabel label3 = new SideBySideBarSeriesLabel();
            this.Detail = new DetailBand();
            this.xrTable3 = new XRTable();
            this.xrTableRow3 = new XRTableRow();
            this.xrTableCell7 = new XRTableCell();
            this.xrTableCell9 = new XRTableCell();
            this.xrTableRow4 = new XRTableRow();
            this.xrTableCell10 = new XRTableCell();
            this.xrTableCell12 = new XRTableCell();
            this.xrLabel3 = new XRLabel();
            this.txtDate = new XRLabel();
            this.chartSalary = new XRChart();
            this.txtCompany = new XRLabel();
            this.xrLabel2 = new XRLabel();
            this.txtAddress = new XRLabel();
            this.ptPhoto = new XRPictureBox();
            this.xrLabel4 = new XRLabel();
            this.TopMargin = new TopMarginBand();
            this.BottomMargin = new BottomMarginBand();
            this.PageFooter = new PageFooterBand();
            this.xrTable3.BeginInit();
            this.chartSalary.BeginInit();
            ((ISupportInitialize) diagram).BeginInit();
            ((ISupportInitialize) series).BeginInit();
            ((ISupportInitialize) label).BeginInit();
            ((ISupportInitialize) series2).BeginInit();
            ((ISupportInitialize) label2).BeginInit();
            ((ISupportInitialize) label3).BeginInit();
            this.BeginInit();
            this.Detail.Controls.AddRange(new XRControl[] { this.xrTable3, this.xrLabel3, this.txtDate, this.chartSalary, this.txtCompany, this.xrLabel2, this.txtAddress, this.ptPhoto, this.xrLabel4 });
            this.Detail.HeightF = 712f;
            this.Detail.Name = "Detail";
            this.Detail.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.Detail.TextAlignment = TextAlignment.TopLeft;
            this.xrTable3.Font = new Font("Times New Roman", 10.25f);
            this.xrTable3.LocationFloat = new PointFloat(2.010886f, 629.1667f);
            this.xrTable3.Name = "xrTable3";
            this.xrTable3.Rows.AddRange(new XRTableRow[] { this.xrTableRow3, this.xrTableRow4 });
            this.xrTable3.SizeF = new SizeF(742.2499f, 62.5f);
            this.xrTable3.StylePriority.UseFont = false;
            this.xrTableRow3.Cells.AddRange(new XRTableCell[] { this.xrTableCell7, this.xrTableCell9 });
            this.xrTableRow3.Name = "xrTableRow3";
            this.xrTableRow3.Weight = 1.0;
            this.xrTableCell7.Font = new Font("Times New Roman", 10.25f, FontStyle.Bold);
            this.xrTableCell7.Name = "xrTableCell7";
            this.xrTableCell7.StylePriority.UseFont = false;
            this.xrTableCell7.StylePriority.UseTextAlignment = false;
            this.xrTableCell7.Text = "Ph\x00f2ng HCNS";
            this.xrTableCell7.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableCell7.Weight = 1.4309860970491313;
            this.xrTableCell9.Font = new Font("Times New Roman", 10.25f, FontStyle.Bold);
            this.xrTableCell9.Name = "xrTableCell9";
            this.xrTableCell9.StylePriority.UseFont = false;
            this.xrTableCell9.StylePriority.UseTextAlignment = false;
            this.xrTableCell9.Text = "Người lập biểu đồ";
            this.xrTableCell9.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableCell9.Weight = 1.5960649703891576;
            this.xrTableRow4.Cells.AddRange(new XRTableCell[] { this.xrTableCell10, this.xrTableCell12 });
            this.xrTableRow4.Name = "xrTableRow4";
            this.xrTableRow4.Weight = 1.0;
            this.xrTableCell10.Font = new Font("Times New Roman", 9.75f, FontStyle.Italic);
            this.xrTableCell10.Name = "xrTableCell10";
            this.xrTableCell10.StylePriority.UseFont = false;
            this.xrTableCell10.StylePriority.UseTextAlignment = false;
            this.xrTableCell10.Text = "(K\x00fd, đ\x00f3ng dấu v\x00e0 ghi r\x00f5 họ t\x00ean)";
            this.xrTableCell10.TextAlignment = TextAlignment.TopCenter;
            this.xrTableCell10.Weight = 1.4309859725920413;
            this.xrTableCell12.Font = new Font("Times New Roman", 9.75f, FontStyle.Italic);
            this.xrTableCell12.Name = "xrTableCell12";
            this.xrTableCell12.StylePriority.UseFont = false;
            this.xrTableCell12.StylePriority.UseTextAlignment = false;
            this.xrTableCell12.Text = "(K\x00fd v\x00e0 ghi r\x00f5 họ t\x00ean)";
            this.xrTableCell12.TextAlignment = TextAlignment.TopCenter;
            this.xrTableCell12.Weight = 1.596065094846248;
            this.xrLabel3.Font = new Font("Times New Roman", 10.25f, FontStyle.Italic | FontStyle.Bold);
            this.xrLabel3.LocationFloat = new PointFloat(353.0109f, 609.6666f);
            this.xrLabel3.Name = "xrLabel3";
            this.xrLabel3.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel3.SizeF = new SizeF(390.3641f, 18.20831f);
            this.xrLabel3.StylePriority.UseFont = false;
            this.xrLabel3.StylePriority.UseTextAlignment = false;
            this.xrLabel3.Text = "............, ng\x00e0y ....... th\x00e1ng ........ năm ...............";
            this.xrLabel3.TextAlignment = TextAlignment.BottomCenter;
            this.txtDate.Font = new Font("Times New Roman", 11.25f, FontStyle.Italic);
            this.txtDate.LocationFloat = new PointFloat(0f, 99.79166f);
            this.txtDate.Name = "txtDate";
            this.txtDate.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtDate.SizeF = new SizeF(742.2499f, 23f);
            this.txtDate.StylePriority.UseFont = false;
            this.txtDate.StylePriority.UseTextAlignment = false;
            this.txtDate.Text = "(Từ th\x00e1ng 00/0000 đến th\x00e1ng 00/0000)";
            this.txtDate.TextAlignment = TextAlignment.MiddleCenter;
            this.chartSalary.BorderColor = SystemColors.ControlText;
            this.chartSalary.Borders = BorderSide.None;
            diagram.AxisX.Range.SideMarginsEnabled = true;
            diagram.AxisX.VisibleInPanesSerializable = "-1";
            diagram.AxisY.Range.SideMarginsEnabled = true;
            diagram.AxisY.VisibleInPanesSerializable = "-1";
            this.chartSalary.Diagram = diagram;
            this.chartSalary.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
            this.chartSalary.Legend.AlignmentVertical = LegendAlignmentVertical.TopOutside;
            this.chartSalary.LocationFloat = new PointFloat(0f, 132.2917f);
            this.chartSalary.Name = "chartSalary";
            label.LineVisible = true;
            series.Label = label;
            series.Name = "Series 1";
            label2.LineVisible = true;
            series2.Label = label2;
            series2.Name = "Series 2";
            this.chartSalary.SeriesSerializable = new Series[] { series, series2 };
            label3.LineVisible = true;
            this.chartSalary.SeriesTemplate.Label = label3;
            this.chartSalary.SizeF = new SizeF(742.2499f, 452.5417f);
            this.txtCompany.Font = new Font("Times New Roman", 9.75f, FontStyle.Bold);
            this.txtCompany.LocationFloat = new PointFloat(93.91676f, 10.00001f);
            this.txtCompany.Name = "txtCompany";
            this.txtCompany.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtCompany.SizeF = new SizeF(648.3333f, 17.70833f);
            this.txtCompany.StylePriority.UseFont = false;
            this.txtCompany.Text = "txtCompany";
            this.xrLabel2.LocationFloat = new PointFloat(93.91676f, 31.70837f);
            this.xrLabel2.Name = "xrLabel2";
            this.xrLabel2.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel2.SizeF = new SizeF(52.79146f, 17.70833f);
            this.xrLabel2.Text = "Địa Chỉ:";
            this.txtAddress.LocationFloat = new PointFloat(146.7082f, 31.70837f);
            this.txtAddress.Name = "txtAddress";
            this.txtAddress.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.txtAddress.SizeF = new SizeF(595.5417f, 17.70833f);
            this.txtAddress.Text = "txtAddress";
            this.ptPhoto.LocationFloat = new PointFloat(2.375f, 4.999987f);
            this.ptPhoto.Name = "ptPhoto";
            this.ptPhoto.SizeF = new SizeF(88.54166f, 58.33333f);
            this.ptPhoto.Sizing = ImageSizeMode.ZoomImage;
            this.xrLabel4.Font = new Font("Times New Roman", 16f, FontStyle.Bold);
            this.xrLabel4.LocationFloat = new PointFloat(0.374999f, 69.54164f);
            this.xrLabel4.Name = "xrLabel4";
            this.xrLabel4.Padding = new PaddingInfo(2, 2, 0, 0, 100f);
            this.xrLabel4.SizeF = new SizeF(743f, 30.25002f);
            this.xrLabel4.StylePriority.UseFont = false;
            this.xrLabel4.StylePriority.UseTextAlignment = false;
            this.xrLabel4.Text = "BIỂU ĐỒ THỐNG K\x00ca CHI TRẢ LƯƠNG";
            this.xrLabel4.TextAlignment = TextAlignment.MiddleCenter;
            this.TopMargin.HeightF = 20f;
            this.TopMargin.Name = "TopMargin";
            this.TopMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.TopMargin.TextAlignment = TextAlignment.TopLeft;
            this.BottomMargin.HeightF = 20f;
            this.BottomMargin.Name = "BottomMargin";
            this.BottomMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.BottomMargin.TextAlignment = TextAlignment.TopLeft;
            this.PageFooter.HeightF = 0f;
            this.PageFooter.Name = "PageFooter";
            base.Bands.AddRange(new Band[] { this.Detail, this.TopMargin, this.BottomMargin, this.PageFooter });
            base.Font = new Font("Times New Roman", 9.75f);
            base.Margins = new System.Drawing.Printing.Margins(0x2d, 0x26, 20, 20);
            base.PageHeight = 0x491;
            base.PageWidth = 0x33b;
            base.PaperKind = PaperKind.A4;
            base.Version = "9.3";
            this.BeforePrint += new PrintEventHandler(this.rptChartSalary_BeforePrint);
            this.xrTable3.EndInit();
            ((ISupportInitialize) diagram).EndInit();
            ((ISupportInitialize) label).EndInit();
            ((ISupportInitialize) series).EndInit();
            ((ISupportInitialize) label2).EndInit();
            ((ISupportInitialize) series2).EndInit();
            ((ISupportInitialize) label3).EndInit();
            this.chartSalary.EndInit();
            this.EndInit();
        }

        public void LoadChartSalary()
        {
            int month = this.m_FromDate.Month;
            int year = this.m_FromDate.Year;
            int num3 = this.m_ToDate.Month;
            int num4 = this.m_ToDate.Year;
            HRM_SALARY hrm_salary = new HRM_SALARY();
            this.chartSalary.Series.Clear();
            Series series = new Series("Tiền lương thực l\x00e3nh", ViewType.Area);
            Series series2 = new Series("Đ\x00e3 thanh to\x00e1n", ViewType.Area);
            Series series3 = new Series("C\x00f2n nợ lại", ViewType.Area);
        Label_01CD:;
            if (((year == num4) && (month <= num3)) || (year < num4))
            {
                DataTable table = hrm_salary.CreateChart(MyLogin.Level, MyLogin.Code, month, year);
                SeriesPoint point = new SeriesPoint(month + "/" + year, new object[] { decimal.Parse(table.Rows[0]["Salary"].ToString()) });
                SeriesPoint point2 = new SeriesPoint(month + "/" + year, new object[] { decimal.Parse(table.Rows[0]["SalaryPay"].ToString()) });
                SeriesPoint point3 = new SeriesPoint(month + "/" + year, new object[] { decimal.Parse(table.Rows[0]["SalaryDebt"].ToString()) });
                series.Points.Add(point);
                series2.Points.Add(point2);
                series3.Points.Add(point3);
                if (month == 12)
                {
                    year++;
                    month = 1;
                }
                else
                {
                    month++;
                }
                goto Label_01CD;
            }
            this.chartSalary.Series.Add(series);
            this.chartSalary.Series.Add(series2);
            this.chartSalary.Series.Add(series3);
            series.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            series2.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            series3.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
        }

        private void rptChartSalary_BeforePrint(object sender, PrintEventArgs e)
        {
            this.LoadChartSalary();
            this.txtDate.Text = string.Concat(new object[] { " Từ th\x00e1ng", this.m_FromDate.Month, "/", this.m_FromDate.Year, " đến th\x00e1ng ", this.m_ToDate.Month, "/", this.m_ToDate.Year });
            ////if (MyInfo.Get(MyEncryption.Encrypt("ERP01", "123654", true)) == "OK")
            {
                this.txtCompany.Text = "";//MyInfo.Company.ToUpper();
                this.txtAddress.Text = "";//MyInfo.Address;
                this.ptPhoto.Image = null;//MyInfo.Photo;
            }
        }
    }
}

